#ifndef WSPACEVIEW_H
#define WSPACEVIEW_H

#include "preheader.h"

namespace Ui {
class WSpaceView;
}

/**
    @file wspaceview.h
    @brief Show the space area and its excitations.
    @author Claus Wimmer
    @date 2013-08-13

    Project: secondspace
    Licence: LGPL (Lesser GPL)
*/
class WSpaceView : public QWidget {

    Q_OBJECT
    
public:

    /**
        @brief Constructor.
        @author Claus Wimmer
        @date 2012-10-05
        @param parent The main application window.
    */
    explicit WSpaceView(QWidget *parent = 0);

    /**
        @brief Free mem.
        @author Claus Wimmer
        @date 2012-10-05
    */
    ~WSpaceView();
    
    /**
        @brief See Qt paint event. Image is copied from ZSpace to the QPainter.
        @author Claus Wimmer
        @date 2012-10-05

        Event data not used.
    */
    void paintEvent(QPaintEvent *);

    /**
        @brief Give a pointer of the image to show to the own instance.
        @author Claus Wimmer
        @date 2012-10-05
        @param image Image pointer or zero.
    */
    void setImage(QImage *image);

    /**
        @brief See Qt events. Point stored and provided to the kernels.
        @author Claus Wimmer
        @date 2012-10-05
        @param _evt Contains the position of the mouse.
    */
    void mousePressEvent(QMouseEvent *_evt);

    /**
        @brief See Qt events.
        @author Claus Wimmer
        @date 2012-10-05

        Event not used.
    */
    void mouseReleaseEvent(QMouseEvent *);

    /**
        @brief See Qt events. Point stored and provided to the kernels.
        @author Claus Wimmer
        @date 2012-10-05
        @param _evt Contains the position of the mouse.
    */
    void mouseMoveEvent(QMouseEvent *_evt);

    /**
        @brief Mouse position relating to the space.
        @author Claus Wimmer
        @date 2013-07-16
        @return Position as point.
    */
    QPoint mousePos();

    /**
        @brief Step by step with the mouse wheel.
        @author Claus Wimmer
        @date 2013-08-03
      */
    void wheelEvent(QWheelEvent *);

public slots:

    /**
        @brief Raised by the space calculation to show its image.
        @author Claus Wimmer
        @date 2012-10-05
    */
    void imageReady();

signals:

    /**
        @brief Notify the kernels about user interaction.
        @author Claus Wimmer
        @date 2012-10-05
        @param x Mouse position.
        @param y Mouse position.
    */
    void mousePointed(uint x, uint y);

    /**
        @brief Trigger a new space calculation step.
        @author Claus Wimmer
        @date 2013-08-03
      */
    void timeout();

private:

    /**
        @brief Mouse is currently pressed and HOVER is seen as DRAG.
        @author Claus Wimmer
        @date 2012-10-05
    */
    bool _mousePressed;

    /**
        @brief Program logo shown during startup in this widget.
        @author Claus Wimmer
        @date 2012-10-05
    */
    QImage _logo;

    /**
        @brief Pointer to the image of the space calculation showing excitation.
        @author Claus Wimmer
        @date 2012-10-05
    */
    QImage *_image;

    /**
        @brief See Qt designer.
        @author Claus Wimmer
        @date 2012-10-05
    */
    Ui::WSpaceView *ui;

    /**
        @brief Number index of the next screenshot file to store.
        @author Claus Wimmer
        @date 2012-10-05
    */
    uint _fileindex;

};
#endif // WSPACEVIEW_H
